package net.lab1024.sa.admin.module.business.test2.controller;

import net.lab1024.sa.admin.module.business.test2.domain.form.Test2AddForm;
import net.lab1024.sa.admin.module.business.test2.domain.form.Test2QueryForm;
import net.lab1024.sa.admin.module.business.test2.domain.form.Test2UpdateForm;
import net.lab1024.sa.admin.module.business.test2.domain.vo.Test2VO;
import net.lab1024.sa.admin.module.business.test2.service.Test2Service;
import net.lab1024.sa.base.common.domain.ValidateList;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import net.lab1024.sa.base.common.domain.ResponseDTO;
import net.lab1024.sa.base.common.domain.PageResult;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.v3.oas.annotations.tags.Tag;
import io.swagger.v3.oas.annotations.Operation;
import cn.dev33.satoken.annotation.SaCheckPermission;
import jakarta.annotation.Resource;
import jakarta.validation.Valid;

/**
 * 计科院活动信息表 Controller
 *
 * @Author mt
 * @Date 2025-07-05 01:56:56
 * @Copyright e
 */

@RestController
@Tag(name = "计科院活动信息表")
public class Test2Controller {

    @Resource
    private Test2Service test2Service;

    @Operation(summary = "分页查询 @author mt")
    @PostMapping("/test2/queryPage")
    @SaCheckPermission("test2:query")
    public ResponseDTO<PageResult<Test2VO>> queryPage(@RequestBody @Valid Test2QueryForm queryForm) {
        return ResponseDTO.ok(test2Service.queryPage(queryForm));
    }

    @Operation(summary = "添加 @author mt")
    @PostMapping("/test2/add")
    @SaCheckPermission("test2:add")
    public ResponseDTO<String> add(@RequestBody @Valid Test2AddForm addForm) {
        return test2Service.add(addForm);
    }

    @Operation(summary = "更新 @author mt")
    @PostMapping("/test2/update")
    @SaCheckPermission("test2:update")
    public ResponseDTO<String> update(@RequestBody @Valid Test2UpdateForm updateForm) {
        return test2Service.update(updateForm);
    }

    @Operation(summary = "批量删除 @author mt")
    @PostMapping("/test2/batchDelete")
    @SaCheckPermission("test2:delete")
    public ResponseDTO<String> batchDelete(@RequestBody ValidateList<Integer> idList) {
        return test2Service.batchDelete(idList);
    }

    @Operation(summary = "单个删除 @author mt")
    @GetMapping("/test2/delete/{id}")
    @SaCheckPermission("test2:delete")
    public ResponseDTO<String> batchDelete(@PathVariable Integer id) {
        return test2Service.delete(id);
    }
}
